import {
  createRouter,
  createWebHashHistory,
  RouteRecordRaw
} from 'vue-router'
const routerView = () => import('@/layout/index.vue')  //一级路由视图
const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/layout/login.vue')
  },
  {
    path: '/',
    name: 'Home',
    redirect: '/home',
    component: routerView,
    meta: {
      title: '员工管理',
    },
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('../views/Home.vue')
      }, {
        path: '/general',
        name: 'General',
        component: () => import('../views/General.vue')
      },
    ]
  },
  {
    path: '/recruit',
    name: 'Recruit',
    redirect: '/recruit',
    component: routerView,
    meta: {
      title: '招聘管理',
    },
    children: [
      {
        path: '/recruit',
        name: 'Recruit',
        component: () => import('../views/Recruit.vue')
      },
      {
        path: '/apply',
        name: 'Apply',
        component: () => import('../views/Apply.vue')
      },
    ]
  }, {
    path: '/clocking',
    name: 'Clocking',
    redirect: '/clocking',
    component: routerView,
    meta: {
      title: '考勤管理',
    },
    children: [
      {
        path: '/clocking',
        name: 'Clocking',
        component: () => import('../views/Clocking.vue')
      },
      {
        path: '/sign',
        name: 'Sign',
        component: () => import('../views/Sign.vue')
      },
    ]
  },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router